//
//  InBrandViewController.m
//  AnXin100
//
//  Created by 王合润 on 10/18/18.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "InBrandViewController.h"
#import "InBrandTableViewCell.h"
#import "StoreViewController.h"
@interface InBrandViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView *mainTable;

@property (nonatomic, strong) UIImageView *headImage;

@end

@implementation InBrandViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    [PublicMonMethods setupNavigationItems:self];
    [PublicMonMethods settitle:@"入驻品牌" viewController:self];
    [self.view addSubview:self.mainTable];
    
}

- (UITableView *)mainTable {
    if (!_mainTable) {
        _mainTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStyleGrouped];
        _mainTable.delegate = self;
        _mainTable.dataSource = self;
        [_mainTable registerClass:[InBrandTableViewCell class] forCellReuseIdentifier:@"InBrandTableViewCell"];
        _mainTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _mainTable;
}

- (UIImageView *)headImage {
    if (!_headImage) {
        
        _headImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 2)];
        _headImage.image = [UIImage imageNamed:@"gfzp"];
    }
    return _headImage;
}

#pragma mark UITableView Delegate

//分区头
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 200)];
    /** 图片比例切 */
    img.contentMode =UIViewContentModeScaleAspectFill;
    img.clipsToBounds=YES;//
    img.image = [UIImage imageNamed:@"gfzp"];
    
    
    
    UIImageView *zpImg = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-140, 50, 100, 100)];
    /** 图片比例切 */
    zpImg.contentMode =UIViewContentModeScaleAspectFill;
    zpImg.clipsToBounds=YES;//
    zpImg.image = [UIImage imageNamed:@"zp"];
    [img addSubview:zpImg];
    
    return img;
    
    
}
/** 分区的高度 */

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    
    return 200;
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 204;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    InBrandTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"InBrandTableViewCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.enterStore = ^{
        StoreViewController *vc = [StoreViewController new];
        [self.navigationController pushViewController:vc animated:YES];
    };
    return cell;
}

- (void)backAction:(UIBarButtonItem *)item {
    [self.navigationController popViewControllerAnimated:YES];
}


@end
